<!--
 * @Author: 迷洛洛ywc
 * @Date: 2024-03-12 16:01:35
 * @LastEditors: 迷洛洛ywc
 * @LastEditTime: 2024-05-06 14:51:07
 * @Description: file content
-->
<template>
  <!-- 农事记录 -->
  <div class="block" style="height: 100%">
    <div
      class="missionList"
      v-for="item in missions"
      :key="item.index"
      @click="openEdit(item)"
    >
      <div class="missionInfo">
        <div class="missionTime">{{ item.time }}</div>
        <div class="missionInfoType">{{ item.type }}</div>
        <div class="missionUser">操作人：{{ item.participants }}</div>
      </div>

      <div class="missionRemark">{{ item.remark }}</div>
      <!-- 防治 -->
        <div class="farmStockList" v-if="item.code === 'NS_FZ'">
          <div
            class="farmsStock"
            v-for="agriList in item.agriList"
            :key="agriList.id"
          >
            <div class="farmsStockIcon">
              <img src="../../../assets/img/huafeiicon.png" alt="" />
            </div>
            <div class="farmsStockName">{{ agriList.name }}</div>
            <div class="farmsStockNum">{{ agriList.num }}公斤</div>
          </div>
        </div>
      <!-- 施肥 -->
        <div class="farmStockList" v-if="item.code === 'NS_SF'" >
      <div class="farmsStock" v-for="agriList in item.agriList" :key="agriList.id" >
          <div class="farmsStockIcon">
            <img src="../../../assets/img/huafeiicon.png" alt="" />
          </div>
          <div class="farmsStockName">{{ agriList.name }}</div>
          <div class="farmsStockNum">{{ agriList.num }}公斤</div>
        </div>
      </div>
      <!-- 播种 -->
      <div class="seed" v-if="item.code === 'NS_BZ'">
        品种：{{ item.seedType }} {{ item.seedInfo }}
        <div class="seedNum" v-if="item.seedNum !== null">
          种子数量：{{ item.seedNum }}
        </div>
        <div class="seedSpacing" v-if="item.seedSpacing !== null">
          种间距：{{ item.seedSpacing }}cm
        </div>
      </div>
      <div
        class="missionImg"
        v-for="(pic, index) in item.picture"
        :key="index"
        @click.stop="pictureBig(pic)"
      >
        <img :src="pic" alt="" />
      </div>
    </div>

    <el-dialog :visible.sync="dialogVisible" width="600" append-to-body>
      <img
        :src="dialogImageUrl"
        style="display: block; max-width: 100%; margin: 0 auto"
      />
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'SevencolorUserArgiMissionComponents',
  props: {
    landMissionData: {
      type: Array
    }
  },

  data () {
    return {
      missions: [],
      dialogImageUrl: '',
      dialogVisible: false
    }
  },
  computed: {
    missionDetail () {
      return this.$store.getters.missionDetail
    }
  },
  mounted () {
    this.changeData()
  },

  methods: {
    // 数据处理
    changeData () {
      // console.log(this.landMissionData)
      this.missions = this.landMissionData
      for (let i = 0; i < this.missions.length; i++) {
        if (
          this.missions[i].picture !== '' &&
          this.missions[i].picture !== null &&
          this.missions[i].picture !== undefined
        ) {
          this.missions[i].picture = this.landMissionData[i].picture
            .split(',')
            .map((picture) => picture)
        } else {
          this.missions[i].picture = []
        }
      }
      console.log(this.missions)
    },
    // 照片放大
    pictureBig (pic) {
      this.dialogImageUrl = pic
      this.dialogVisible = true
    },
    // 详情
    openEdit (data) {
      if (data.code === 'NS_BZ') {
        this.$message('请点击作物查看播种详情')
      } else if (data.code !== 'NS_BZ') {
        this.$store.dispatch('mission/updatemissionDetail', data)
        // console.log(this.missionDetail)
        this.$router.push({
          path: '/shuzhongtian/agriMissionAdd',
          query: {
            ...this.$route.query
          }
        })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.missionList {
  width: 77.0833vw;
  // height: 16.6667vw * 0.834;
  min-height: 8vw*0.834;
  background: #edf1f4;
  border-radius: 12px 12px 12px 12px;
  padding: 1.0417vw * 0.834 1.0417vw;
  margin-bottom: 1.5vw;
}
.missionInfo {
  display: flex;
  .missionTime {
    width: 8.3333vw;
    height: 1.5625vw * 0.834;
    background: #19b560;
    border-radius: 8px 8px 8px 8px;
    margin-right: 20px;
    text-align: center;
    line-height: 1.5625vw * 0.834;
    font-weight: 500;
    font-size: 1.0417vw;
    color: #fff;
  }
  .missionInfoType {
    // width: 8.1667vw;
    padding: 0 1vw;
    height: 1.5625vw * 0.834;
    background: #19b560;
    border-radius: 8px 8px 8px 8px;
    margin-right: 20px;
    line-height: 1.5625vw * 0.834;
    text-align: center;
    font-weight: 500;
    font-size: 1.0417vw;
    color: #fff;
  }
  .missionUser {
    width: 10.1667vw;
    height: 1.5625vw * 0.834;
    line-height: 1.5625vw * 0.834;
    font-weight: 500;
    font-size: 1.0417vw;
  }
}
.missionRemark {
  font-weight: 400;
  font-size: 1.0417vw;
  color: #666666;
  margin: 1.0417vw * 0.834 0 0.5208vw * 0.834;
}
.farmStockList {
  width: 70vw;
  display: flex;
}
.farmsStock {
  width: 18.75vw;
  height: 3.2813vw * 0.834;
  margin-right: 1.0417vw;
  background: #e4e7e9;
  border-radius: 12px 12px 12px 12px;
  display: flex;
  line-height: 3.2813vw * 0.834;
  font-size: 0.9375vw;
  .farmsStockIcon {
    width: 1.6667vw;
    height: 1.6667vw;
    margin: auto 1.0417vw;
  }
  .farmsStockName {
    margin: 0 1.5625vw 0 0;
    color: #647f93;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
  }
  .farmsStockNum {
    color: #647f93;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
  }
}
.missionImg {
  margin-top: 0.5208vw * 0.834;
  width: 5.5vw;
  height: 5.5vw;
  background: #dcdedf;
  border-radius: 12px 12px 12px 12px;
  display: inline-block;
  margin-right: 0.8208vw;
  img {
    width: 5.5vw;
    height: 5.5vw;
  }
}
</style>
